           package com.java.diagnostics.visualizer.impl.extensions;
           
           import com.java.diagnostics.visualizer.parsers.Parser;
           import java.util.HashSet;
           import java.util.List;
           import java.util.Set;
           import org.eclipse.core.runtime.IConfigurationElement;
           import org.eclipse.core.runtime.IExtension;
           
           public class ParserRegistry extends GCAndMemoryVisualizerExtensionRegistry
           {
             public static final String CATEGORY = "category";
             private static final String EXTENSION_POINT = "com.java.diagnostics.visualizer.parser";
             private static final String[] STRING_TEMPLATE_ARRAY = new String[0];
           
             private static final Parser[] PARSER_TEMPLATE_ARRAY = new Parser[0];
           
             private static String[] categories = null;
           
             private static ParserRegistry registry = null;
           
             public static ParserRegistry getInstance()
             {
               if (registry == null)
               {
                 registry = new ParserRegistry();
               }
           
               return registry;
             }
           
             public String[] getCategories()
             {
               if (categories == null)
               {
                 Set categoriesSet = new HashSet();
                 IExtension[] extensions = getExtensions();
           
                 for (int i = 0; i < extensions.length; i++)
                 {
                   IExtension extension = extensions[i];
                   IConfigurationElement[] elements = extension
                     .getConfigurationElements();
           
                   for (int j = 0; j < elements.length; j++) {
                     IConfigurationElement element = elements[j];
           
                     String categoryName = element.getAttribute("category");
                     categoriesSet.add(categoryName);
                   }
           
                   categories = (String[])categoriesSet.toArray(STRING_TEMPLATE_ARRAY);
                 }
           
               }
           
               return (String[])categories.clone();
             }
           
             protected String getExtensionPointID()
             {
               return "com.java.diagnostics.visualizer.parser";
             }
           
             public Parser[] instantiateParsers()
             {
               List parsers = instantiateExtensions();
           
               return (Parser[])parsers.toArray(PARSER_TEMPLATE_ARRAY);
             }
           }

